<?php
require_once 'global.inc.php';
require_once 'classes/class.upload.php';

//check to see if they're logged in
if(!isset($_SESSION['admin_logged_in'])) {
	header("Location: index.php");
}
//get the user object from the session
$user = unserialize($_SESSION['admin_user']);

$productId = $_GET['product'];
$product = $GLOBALS['DB']->select("items","item_id=".$productId);
$insertId = $GLOBALS['DB']->remove("items", "item_id=".$productId);
if ($insertId) {
	// remove image
	$uploader = new Uploader();
	$uploader->deleteImage(BASE_PATH.'upload/'.$product['picture']);
	header("Location: main.php");
}

?>
<!DOCTYPE html>
<html>
	<?php include 'header.php';?>
	<body>
		<!-- Navigation start -->
		<div class="navbar navbar-inverse navbar-fixed-top">
			<div class="navbar-inner">
				<div class="container">
					<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
						<span class="icon-bar"></span>
						<span class="icon-bar"></span>
						<span class="icon-bar"></span>
					</button>
				</div>
			</div>
		</div>
		<!-- Navigation end -->

		<!-- Content start -->
		<div class="container">
			<div class="row">
				<div class="span12">
				</div>
			</div>
		</div>


		<!-- Content end -->
		<?php include 'footer.php';?>
		<!-- Javascript -->
		<script src="js/jquery.js"></script>
		<script src="js/bootstrap.min.js"></script>
	</body>
</html>